package code.structure.module.scene.view.bg
{
	import code.structure.manager.loader.DllLoaderManager;
	import code.untils.LoaderTypeConst;
	
	import flash.display.BitmapData;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	
	/**
	 *背景图小块信息 
	 * @author Yuri
	 * 
	 */
	public class BackGroundItemInfo extends EventDispatcher
	{
		/**
		 *是否加载完成 
		 */
		private var _isLoadComplete:Boolean;
		private var _xIndex:int;
		private var _yIndex:int;
		private var _bitmapData:BitmapData;
		public function BackGroundItemInfo(xI:int,yI:int)
		{
			_xIndex = xI;
			_yIndex = yI;
		}
		
		/**
		 *加载素材 
		 * @param path
		 * 
		 */
		public function loadMaterial(path:String):void{
			DllLoaderManager.getInstance().getMaterial(path,"",onDllgetMaterialHandler,"png",LoaderTypeConst.LOADER_TYPE_BACKGROUND);
		}
		
		private function onDllgetMaterialHandler(bd:BitmapData,key:String = ""):void
		{
			// TODO Auto Generated method stub
			_bitmapData = bd.clone();
			_isLoadComplete = true;
			dispatchEvent(new Event(DATA_COMPLETE_EVENT));
		}
		
		public function get isLoadComplete():Boolean
		{
			return _isLoadComplete;
		}

		/**
		 *索引位置X 
		 */
		public function get xIndex():int
		{
			return _xIndex;
		}

		/**
		 *索引位置Y 
		 */
		public function get yIndex():int
		{
			return _yIndex;
		}

		/**
		 *位图数据 
		 */
		public function get bitmapData():BitmapData
		{
			return _bitmapData;
		}

		
		public static const DATA_COMPLETE_EVENT:String = "DATA_COMPLETE_EVENT";
	}
}